/**
* 
* ====================================================================
*
* @author apov <apov@ymail.com>
*/ 
#pragma once

#include <BaseDefine.h>

class DBError;
class DBSession;
class DBResultSet;
/**
* @class DBStatement
*  - 
*/ 
class DBStatement{
public:
	enum{
		DEF_PARAM_TYPE_INPUT,
		DEF_PARAM_TYPE_OUTPUT,
		DEF_PARAM_TYPE_INOUTPUT,
	};

	virtual int executeUpdate() = 0;
	virtual DBResultSet* executeQuery() = 0;
	virtual int prepare( int result_type ) = 0;	
	virtual DBSession* getSession() = 0;

	virtual void setByte( char& value, short flag ) = 0;
	virtual void set2Byte( short& value, short flag ) = 0;	
	virtual void set4Byte( int& value, short flag ) = 0;	
	virtual void set4Byte( unsigned int& value, short flag ) = 0;	
	virtual void set8Byte( __int64& value, short flag ) = 0;	
	virtual void setFloat( float& value, short flag ) = 0;
	virtual void setString( char* value, short flag, int size = 0 ) = 0;		
	virtual void setDate( char* value, short flag ) = 0;
	virtual void setMemory( char* value, int size, short flag ) = 0;
	virtual void setNull() = 0;
	virtual void setReal( double& value, int precision, int scale, short flag ) = 0;
	virtual int is_procedure() = 0;

	int set_sql( char* sql_statement, ... );
	char* get_sql(){ return sql_; }

	void reset();

	DBStatement( DBSession* session );
	virtual ~DBStatement();

protected:
	enum{
		DEF_SQL_LEN=		4096,
	};

	char sql_[ DEF_SQL_LEN ];
	DBSession* session_;

private:
};
